package cn.mediatek.server;

import cn.hutool.core.io.FileUtil;

import java.io.File;

public class Tee {
    public static void main(String[] args) {
        String path = "D:\\照片";
        String splitPath = "D:\\照片\\bak\\";

        normal(path, splitPath + "1.jpg", "JPG");

        normal(path, splitPath + "2.raw", "dng");
        normal(path, splitPath + "2.raw", "xmp");
        normal(path, splitPath + "2.raw", "ARW");

        normal(path, splitPath + "3.mp4", "MP4");

    }
    public static void normal(String path, String splitPath, String suffixName) {
        File[] dirList = FileUtil.ls(path);
        for (File dirName : dirList) {
            if(dirName.getName().contains("2024") && FileUtil.isDirectory(dirName)) {
                File[] fileList = FileUtil.ls(dirName.getPath());
                String dirTempName = splitPath + "\\" + dirName.getName();
                for (File fileName : fileList) {
                    if (suffixName.equalsIgnoreCase(FileUtil.getSuffix(fileName))) {
                        String oriFile = FileUtil.getAbsolutePath(fileName);
                        String desFile = dirTempName + "\\" + fileName.getName();
                        FileUtil.move(new File(oriFile), new File(desFile), true);
                        System.out.println(oriFile +"  >>>>  " + desFile);
                    }
                }
            }
        }
    }

    public static void spec() {
        String path = "D:\\照片\\11\\bak";
        String splitPath = "D:\\照片\\11\\raw";
        String suffixName = "ARW";
        File[] dirList = FileUtil.ls(path);
        for (File dirName : dirList) {
            // dirName: 2024-3-2
            if(FileUtil.isDirectory(dirName)) {
                String rawDir = dirName.getPath() + "\\raw";
                if (FileUtil.isDirectory(rawDir)) {
                    File[] fileList = FileUtil.ls(rawDir);
                    String dirTempName = splitPath + "\\" + dirName.getName();
                    for (File fileName : fileList) {
                        if (suffixName.equals(FileUtil.getSuffix(fileName))) {
                            String oriFile = FileUtil.getAbsolutePath(fileName);
                            String desFile = dirTempName + "\\" + fileName.getName();
                            FileUtil.move(new File(oriFile), new File(desFile), true);
                            System.out.println(oriFile + "  >>>>  " + desFile);
                        }
                    }
                }
            }
        }
    }
}
